// Create Summary Statistics Table
* Pilot A 
use ../dta/stock_daily.dta, clear 
keep if date == mdy(2,10,2010)
merge 1:1 code using "../src/0th_shsz.dta"

collapse (sum) float_cap, by(_merge)
gen k = 1 
ren _merge m
reshape wide float_cap, i(k) j(m)
gen r = float_cap3/(float_cap1+float_cap3)
disp r
qui sum r
scalar cap1=round(r(mean)*100, 0.01)



* Pilot B 
use ../dta/stock_daily.dta, clear 
keep if date == mdy(11,25,2011)
merge 1:1 code using "../src/1st_shsz.dta"

collapse (sum) float_cap, by(_merge)
gen k = 1 
ren _merge m
reshape wide float_cap, i(k) j(m)
gen r = float_cap3/(float_cap1+float_cap3)
disp r
qui sum r
scalar cap2=round(r(mean)*100, 0.01)

* Vintage 1 
use ../dta/stock_daily.dta, clear 
keep if date == mdy(1,25,2013)
merge 1:1 code using "../src/2nd_shsz.dta"

collapse (sum) float_cap, by(_merge)
gen k = 1 
ren _merge m
reshape wide float_cap, i(k) j(m)
gen r = float_cap3/(float_cap1+float_cap3)
disp r
qui sum r
scalar cap3=round(r(mean)*100, 0.01)

* Vintage 2 
use ../dta/stock_daily.dta, clear 
keep if date == mdy(9,6,2013)
merge 1:1 code using "../src/3rd_shsz.dta"

collapse (sum) float_cap, by(_merge)
gen k = 1 
ren _merge m
reshape wide float_cap, i(k) j(m)
gen r = float_cap3/(float_cap1+float_cap3)
disp r
qui sum r
scalar cap4=round(r(mean)*100, 0.01)


* Vintage 3
use ../dta/stock_daily.dta, clear 
keep if date == mdy(9,12,2014)
merge 1:1 code using "../src/4th_shsz.dta"

collapse (sum) float_cap, by(_merge)
gen k = 1 
ren _merge m
reshape wide float_cap, i(k) j(m)
gen r = float_cap3/(float_cap1+float_cap3)
disp r
qui sum r
scalar cap5=round(r(mean)*100, 0.01)

// Outputting Result
matrix NewMarg = (cap1, cap2, cap3, cap4, cap5)
matrix rownames NewMarg = "\% Floating Cap"
matrix colnames NewMarg = "Pilot A" "Pilot B" "1" "2" "3"
eststo clear
matrix list NewMarg
esttab matrix(NewMarg) using ../esttab/Tab1.tex, replace ///
    noobs       /// hide the "Observations" row
    nonumber  cells("b(fmt(%9.4g))")  


